package com.dily.study.demo.proxy;

/**
 * Date: 2022-08-09 星期二
 * Time: 16:44
 * Author: Dily_Su
 * Remark:
 * 静态代理模式
 */
public class StaticProxy{

    public static void main(String[] args) {
        WeddingCompany weddingCompany = new WeddingCompany(new You());
        weddingCompany.happyMarry();
    }
}


interface Marry{
    /**
     * 人生四大喜事
     * 久旱逢甘霖
     * 他乡遇故知
     * 洞房花烛夜
     * 金榜题名时
     */
    void happyMarry();
}

// 真实角色，你去结婚
class You implements Marry{

    @Override
    public void happyMarry() {
        System.out.println("Dily要结婚了, 超级开心！！！");
    }
}

// 代理对象，帮助你结婚
class WeddingCompany implements Marry{

    private Marry target;

    WeddingCompany(Marry target) {
        this.target = target;
    }

    @Override
    public void happyMarry() {
        before();
        target.happyMarry();
        after();
    }

    private void after() {
        System.out.println("结婚后,收尾款");
    }

    private void before() {
        System.out.println("结婚前,布置现场");
    }
}